import { message } from 'antd';
import { setGpsIntvTime, getGpsIntvTime } from '../services/api';

export default {
  namespace: 'gpsintervaltime',

  state: {
    gpsParamInfo: {},
  },

  effects: {
    *saveParam({ payload }, { call, put }) {
      //console.log('saveParam', payload);
      const response = yield call(setGpsIntvTime, payload);
      if (response) {
        message.success('数据保存成功！');
      }
    },
    *getParam({ payload }, { call, put }) {
      const response = yield call(getGpsIntvTime, payload);
      if (response) {
        yield put({
          type: 'getGpsParam',
          payload: response.getParamInfo,
        });
      }
    },
  },
  reducers: {
    getGpsParam(state, action) {
      return {
        ...state,
        gpsParamInfo: action.payload,
      };
    },
  },
};
